package cn.wen.eeayjoke.app;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;

/**
 * 初始化的服务
 */

public class InitService extends IntentService {
    private static final String SERVICE_ACTION = "wen.initialize.service";

    public InitService() {
        super("InitService");
    }

    public static void init(Context context) {
        Intent intent = new Intent(context, InitService.class);
        intent.setAction(SERVICE_ACTION);
        intent.addCategory("cn.wen.eeayjoke");
        context.startService(intent);
    }

    /**
     * 这个方法可以做耗时的操作
     */
    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        if (intent != null) {
            final String action = intent.getAction();
            if (SERVICE_ACTION.equals(action)) {
                InitUtils.getInstance().initOthers();
            }
        }
    }
}
